<?php
/**
 * UserInventory.php
 *
 * @copyright   2023 thingsworld.com.cn - All Rights Reserved
 * @link        http://thingsworld.com.cn/
 * @author      stiffer.chen <chenl@thingsworld.com.cn>
 * @created     2023-05-22 11:39:55
 * @modified    2023-05-22 11:39:55
 *
 */

namespace App\Models;

class UserInventory extends BaseModel
{
    protected $table = 'user_inventory';
    protected $primaryKey = 'id';
    public $timestamps = true;
    public const CREATED_AT = 'create_time';
    public const UPDATED_AT = 'update_time';

    protected $fillable = [
        'c_id',
        'user_id',
        'warehouse_id',
        'c_id',
        'c_name',
        'c_number',
        'type',
        'model',
        'uom',
        'sale_price',
        'out_price',
        'description',
        'inventory',
        'safe_inventory',
        'disabled_inventory',
        'create_user_id'
    ];

    public function scopeByCid($query, $cid)
    {
        return $query->where('c_id', $cid);
    }

    public function scopeByWareHouseId($query, $warehouseId)
    {
        return $query->where('warehouse_id', $warehouseId);
    }

    public function scopeByUserId($query, $userId)
    {
        return $query->where('user_id', $userId);
    }
}